package com.jet.chat.dbquery;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class ChatQueryReadConfirmation extends ChatQueryAbstract {

	@Override
	protected ChatQueryResult main(Connection conn, ChatQueryParams chatQueryParams) throws Exception {
		
		int messageId = ((ChatQueryReadConfirmationParams) chatQueryParams).getMessageId();
		int userId = ((ChatQueryReadConfirmationParams) chatQueryParams).getUserId();
		
		PreparedStatement ps = conn.prepareStatement("update isread set isread = ? where messageid = ? and userid = ?");
		ps.setInt(1, 1);
		ps.setInt(2, messageId);
		ps.setInt(3, userId);
		ps.execute();
		
		conn.commit();
		
		return null;
	}

}
